home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / watchit1.zip / WATCHCAT.ASM < prev    next >
Assembly Source File  |  1989-08-23  |  7KB  |  286 lines

  1.  page ,132
  2.  .model tiny
  3.  .code
  4. first:
  5. ;
  6. ; WATCHCAT copyright 1989, Joseph R. Ahlgren
  7. ;  see WATCHCAT.DOC
  8. ;
  9. ; WATCHCAT performs 5 critical functions for any RBBS system:
  10. ;  1.  Reboots system if no carrier in specified period of time
  11. ;    This catches RBBS or system failures
  12. ;  2.  Reboots system if carrier lost during critical period
  13. ;    This allows Doors to be used safely
  14. ;  3.  Reboots system if 20 rings without answering phone
  15. ;    This allows system to be restarted by phone
  16. ;  4.  Reboots system if "Hit any key to return to system" message appears
  17. ;    This restarts system on a common RBBS failure
  18. ;  5.  Drops carrier if L&R shift keys pressed simultaneously
  19. ;    This allows users to be logged off without a nasty message.
  20. ;WATCHCAT loads the TSR and disables all functions
  21. ; WATCHCAT OFF disables all functions
  22. ; WATCHCAT ON enables 1,3,4,and 5
  23. ; WATCHCAT TIMER enables 2,4,and 5
  24. ;ComPort = 03f8h  ;{COM1}
  25. ;ComPort = 02f8h  ;{COM2}
  26. ;ComPort = 03e8h  ;{COM3}
  27. ;ComPort = 02e8h  ;{COM4}
  28. ;ScreenSegment = 0b800h  ;{Color}
  29. ;ScreenSegment = 0b000h  ;{Mono}
  30. ModemStatus = 0006h
  31. ModemControl = 0004h
  32. CarrierDetect = 0080h
  33. RingIndicator = 0040h
  34. tpm = 1092 ; {ticks per minute}
  35. RingTicks = 110; {6 seconds}
  36.  org 100h
  37. start:
  38.  jmp init
  39. RingTrigger dw 0
  40. RingTimer db 0
  41. Flag db 'F' and 0fh  ;  OFF ON TIME = F O I
  42. TimerInt dd ?
  43. Minutes dw 8*60  ;{minutes of no carrier to trigger reset}
  44. Seconds dw tpm
  45. MinReset dw 8*60
  46. ColdBoot dd 0ffff0000h
  47. ExitTimer db 0
  48. DropTrigger db 3  ;Drop DTR on L&R shift
  49. ExitMessage db 'Hit any key to return to system'
  50. ExitMessageEnd db 0
  51. ComPort dw 02f8h  ;{COM2}
  52. ScreenSegment dw 0b000h  ;{Mono}
  53. Ident db "jOeY"
  54. Ident2 db "50c4"
  55. timer:
  56.  assume ds:nothing,es:nothing,ss:nothing
  57.  cmp cs:[Flag],'F' and 0fh
  58.  jne SystemOn
  59.  jmp cs:[TimerInt]
  60. SystemOn:
  61.  push ax
  62.  push dx
  63.  push ds
  64. ;  4.  Reboots system if "Hit any key to return to system" message appears
  65. ;    This restarts system on a common RBBS failure
  66.  dec cs:[ExitTimer]
  67.  jnz NoExitLoop
  68.  push cx
  69.  push si
  70.  push di
  71.  mov ax,cs:[ScreenSegment]
  72.  mov ds,ax
  73.  mov cx,25
  74.  xor si,si
  75. SSLoop1:
  76.  push cx
  77.  push si
  78.  mov cx,ExitMessageEnd-ExitMessage
  79.  mov di,offset ExitMessage
  80. SSLoop2:
  81.  lodsw
  82.  cmp al,cs:[di]
  83.  jne SSLoop2x
  84.  inc di
  85.  loop SSLoop2
  86.  jmp short NoCarrier
  87. SSLoop2x:
  88.  pop si
  89.  pop cx
  90.  add si,160
  91.  loop SSLoop1
  92.  pop di
  93.  pop si
  94.  pop cx
  95. NoExitLoop:
  96. ;  5.  Drops carrier if L&R shift keys pressed simultaneously
  97. ;    This allows users to be logged off without a nasty message.
  98.  xor ax,ax
  99.  mov ds,ax
  100.  assume ds:Lowmem
  101.  mov al,[ShiftStatus]
  102.  and al,0fh
  103.  cmp al,cs:[DropTrigger]
  104.  jne NoShift
  105.  mov dx,cs:[ComPort]
  106.  add dx,ModemControl
  107.  in al,dx
  108. ; or al,1
  109.  and al,0feh
  110.  out dx,al       ;drop DTR
  111. NoShift:
  112. ;  3.  Reboots system if 20 rings without answering phone
  113. ;    This allows system to be restarted by phone
  114.  mov dx,[ComPort]
  115.  add dx,ModemStatus
  116.  in al,dx
  117.  test al,RingIndicator
  118.  jz NotRinging
  119.  or cs:[RingTrigger],1
  120. NotRinging:
  121.  dec cs:[RingTimer]
  122.  jnz NoRingTime
  123.  mov cs:[RingTimer],RingTicks
  124.  mov ax,cs:[RingTrigger]
  125.  cmp ax,0ffffh
  126.  je NoCarrier
  127.  shl ax,1
  128.  mov cs:[RingTrigger],ax
  129. ;  2.  Reboots system if carrier lost during critical period
  130. ;    This allows Doors to be used safely
  131. NoRingTime:
  132.  cmp cs:[Flag],'I' and 0fh
  133.  jb NoMonitor
  134.  je TimeCheck
  135.  in al,dx
  136.  and al,CarrierDetect
  137.  jz NoCarrier
  138. NoMonitor:
  139.  pop ds
  140.  pop dx
  141.  pop ax
  142.  jmp cs:[TimerInt]
  143. NoCarrier:
  144.  jmp cs:[ColdBoot]
  145. ;  1.  Reboots system if no carrier in specified period of time
  146. ;    This catches RBBS or system failures
  147. TimeCheck:
  148.  test al,CarrierDetect
  149.  jnz ResetTime
  150.  dec cs:[Seconds]
  151.  jnz NoMonitor
  152.  mov cs:[Seconds],tpm
  153.  dec cs:[Minutes]
  154.  jz NoCarrier
  155.  jmp short NoMonitor
  156. ResetTime:
  157.  mov ax,cs:[MinReset]
  158.  mov cs:[Minutes],ax
  159.  jmp short NoMonitor
  160. ;
  161. ;
  162. ;
  163. ;
  164.  assume ds:@code,es:@code,ss:@code
  165. init:
  166.  mov dx,offset SignOnMessage
  167.  mov ax,0900h
  168.  int 21h     ;print load message
  169.  mov ax,[word ptr Ident2]
  170.  xor [word ptr Ident],ax
  171.  mov ax,[word ptr Ident2+2]
  172.  xor [word ptr Ident+2],ax
  173.  xor dx,dx
  174.  mov es,dx
  175.  mov si,offset Ident
  176.  mov cx,cs
  177.  mov ax,[si]
  178. findloop:
  179.  cmp ax,es:[si]
  180.  jz found
  181. NotQuite:
  182.  inc dx
  183.  mov es,dx
  184.  loop findloop
  185. LoadWatchCat:
  186.  xor bx,bx
  187.  mov es,bx
  188.  mov bl,ds:[82h]
  189.  cmp bl,'0'
  190.  jle NoCom
  191.  cmp bl,'4'
  192.  jle ComSpec
  193. NoCom:
  194.  mov bl,'1'
  195. ComSpec:
  196.  mov [ComPortNumber],bl
  197.  add bx,bx
  198.  mov ax,es:[bx+400h-31h-31h]
  199.  mov [ComPort],ax
  200.  cmp byte ptr ds:[83h],'C'
  201.  jnz NotColor
  202.  mov [ScreenSegment],0b800h
  203.  mov [ScreenSegNum],'8'
  204. NotColor:
  205.  mov ax,3508h
  206.  int 21h     ;get timer interrupt
  207.  mov [word ptr TimerInt],bx
  208.  mov [word ptr TimerInt+2],es
  209.  mov dx,offset Timer
  210.  mov ax,2508h
  211.  int 21h     ;set timer interrupt
  212.  mov dx,offset message1
  213.  mov ax,0900h
  214.  int 21h     ;print load message
  215.  mov dx,(init-first+15)/16
  216.  mov ax,3101h
  217.  int 21h      ;TSR
  218. Found:
  219.  mov bx,[si+2]
  220.  cmp bx,es:[si+2]
  221.  jnz NotQuite
  222.  mov ax,es
  223.  mov bx,10h
  224.  mov di,offset message2x
  225.  mov cx,4
  226. loc:
  227.  mul bx
  228.  cmp dl,9
  229.  jbe locx
  230.  add dl,7
  231. locx:
  232.  add dl,'0'
  233.  mov [di],dl
  234.  inc di
  235.  loop loc
  236.  mov ax,es:[MinReset]
  237.  mov es:[Minutes],ax
  238.  mov al,ds:[83h]
  239.  and al,0fh
  240.  mov es:[Flag],al
  241.  mov dx,offset message2tim
  242.  cmp al,'I' and 0fh
  243.  jz done
  244.  mov dx,offset message2off
  245.  jb done
  246.  mov dx,offset message2on
  247. done:
  248.  push dx
  249.  mov dx,offset message2
  250.  mov ax,0900h
  251.  int 21h
  252.  pop dx
  253.  mov ax,0900h
  254.  int 21h
  255.  mov ax,4c00h
  256.  int 21h
  257. message1 db 0ah,0dh,'Watchcat Loaded, set to COM'
  258. ComPortNumber db '1 and Screen B'
  259. ScreenSegNum db '000',0ah,0dh,'$'
  260. message2 db 0ah,0dh,'Watchcat found at '
  261. message2x db '0000 and set to $'
  262. message2on db 'ON',0ah,0dh,'$'
  263. message2off db 'OFF',0ah,0dh,'$'
  264. message2tim db 'TIMER',0ah,0dh,'$'
  265. SignOnMessage db 0dh,0ah,'WATCHCAT, copyright 1989 Joseph R. Ahlgren'
  266.  db '   RBBS 703-241-7980',0dh,0ah
  267.  db ' WATCHCAT may be freely distributed provided this message is not modified',0dh,0ah
  268.  db ' Load with WATCHCAT ps, where p is the port number (1,2,3,4)',0dh,0ah
  269.  db '  and s is the screen type (Color or Mono), e.g., WATCHCAT 2C',0dh,0ah
  270.  db '  specifies COM2 and Color Screen',0ah,0dh
  271.  db ' Subsequent calls are WATCHCAT ON, WATCHCAT OFF, and WATCHCAT TIMER',0dh,0ah
  272.  db '  OFF disables all functions',0dh,0ah
  273.  db '  ON reboots if carrier lost',0dh,0ah
  274.  db '  TIMER reboots if 20 rings without answering phone, if no carrier',0dh,0ah
  275.  db '   in 8 hours, or if "Hit any key to return to system" appears on screen',0dh,0ah
  276.  db '   Also, pressing both Left and Right Shift keys simultaneously will',0dh,0ah
  277.  db '   drop the line, logging off the current user.',0dh,0ah
  278.  db '$'
  279.  ends
  280. Lowmem segment at 0000h
  281.  org 417h
  282. ShiftStatus db ?
  283. Lowmem ends
  284.  end start
  285.  
  286.